package com.huawei.M01.iterator.M14;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class Tset04 {
    public static void main(String[] args) {
        Map<Key, String> map = new HashMap<>();
        Key key = new Key(10, 20);
        map.put(key, "test");
        System.out.println(map.get(key));
        key.setFir(30);
        System.out.println(map.get(key));
        key.setFir(10);
        System.out.println(map.get(key));
    }
}
class Key {
    private int fir;
    private int sec;

    public Key(int fir, int sec) {
        this.fir = fir;
        this.sec = sec;
    }

    public int getFir() {
        return fir;
    }

    public void setFir(int fir) {
        this.fir = fir;
    }

    public int getSec() {
        return sec;
    }

    public void setSec(int sec) {
        this.sec = sec;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Key key = (Key) o;
        return fir == key.fir && sec == key.sec;
    }

    @Override
    public int hashCode() {
        return Objects.hash(fir, sec);
    }
}
